﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace com.IronOne.BoardAppWeb.Models.Meeting
{
    public class MeetingModel
    {
        public int MeetingId { get; set; }
        public DateTime? Date { get; set; }
        public int SubCategoryId { get; set; }
        public string SubCategoryName { get; set; }
        public string Subject { get; set; }
        public string Description { get; set; }
        public byte MeetingStatus { get; set; }
        public int CategoryId { get; set; }
        public string AllowedActions { get; set; }
        public string startTime { get; set; }
        public string endTime { get; set; }
        public bool isTentative { get; set; }
        public int previosStatus { get; set; }
        public TimeSpan setStartTime { get; set; }
        public int meetingType { get; set; }
        public string meetingTypeName { get; set; }

        public override string ToString() 
        {
            return " " + this.MeetingId + " " + this.Date + " " + this.SubCategoryId + " "
                + this.SubCategoryName + " " + this.Subject + " " + this.Description + " " + this.MeetingStatus + " "+this.CategoryId + " "+this.AllowedActions+" "+this.startTime+" "+this.endTime+" ";
        }

        public DateTime? StartDateWithTime
        {
            get
            {
                try
                {
                    if (!isTentative)
                    {
                        return ((DateTime)this.Date).Date + (TimeSpan.Parse(this.startTime)); 
                    }
                    else
                    {
                        return this.Date;
                    }
                }
                catch (Exception)
                {
                    return null;
                    //throw;
                }
            }
        }

        public DateTime? EndDateWithTime
        {
            get
            {
                try
                {
                    if (!isTentative)
                    {
                        return ((DateTime)this.Date).Date + (TimeSpan.Parse(this.endTime));
                    }
                    else
                    {
                        return this.Date;
                    }
                }
                catch (Exception)
                {
                    return null;
                }
            }
        }
    }

    public enum MeetingType : byte 
    {
        Meeting= 0,
        Circular
    }

    public enum MeetingStatus : byte
    {
        Pending = 0,
        Open,
        Close,
        Cancelled,       
        Confirmed
    }
}